<%@ page language="java" contentType="text/html; charset=utf-8"
		 pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
	<title>客户修改</title>
	<meta charset="utf-8"/>
	<link rel="stylesheet" href="../css/bootstrap.css"/>
	<script type="text/javascript" src="../easyui/jquery.min.js"></script>
</head>
<body>
<div class="container-fluid">

	<jsp:include page="../admin/header.jsp"></jsp:include>

	<br><br>

	<form class="form-horizontal" action="" method="post">
		<input type="hidden" name="id" id="id" value="${u.id }">
		<div class="form-group">
			<label for="input_name" class="col-sm-1 control-label">用户名</label>
			<div class="col-sm-5">${u.userName }</div>
		</div>
		<div class="form-group">
			<label for="input_name" class="col-sm-1 control-label">邮箱</label>
			<div class="col-sm-5">${u.email }</div>
		</div>
		<div class="form-group">
			<label for="input_name" class="col-sm-1 control-label">收货人</label>
			<div class="col-sm-6">
				${u.firstName } ${u.lastName }
			</div>
		</div>
		<div class="form-group">
			<label for="input_name" class="col-sm-1 control-label">电话</label>
			<div class="col-sm-6">
				<input type="text" class="form-control" id="phone" name="phone" value="${u.phone }">
			</div>
		</div>
		<div class="form-group">
			<label for="input_name" class="col-sm-1 control-label">地址</label>
			<div class="col-sm-6">
				<input type="text" class="form-control" id="address" name="address" value="${u.address }">
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-offset-1 col-sm-10">
				<button type="button" class="btn btn-success" onclick="updateUser()">提交修改</button>
			</div>
		</div>
	</form>

	<span style="color:red;"></span>

</div>
</body>
<script type="text/javascript">
function updateUser(){
    $.ajax({
        type: "post",
        url: "../admin/user_edit",
        data: JSON.stringify({
            id:$("#id").val(),
            address:$("#address").val(),
            phone:$("#phone").val(),
        }),
        dataType: 'json',
        contentType:"application/json;charset=UTF-8",
        success: function(data, textStatus) {
            if (data.success){
            	window.location="../admin/user_list";
            }
        },
        complete : function(XMLHttpRequest, textStatus) {
        },
        error : function(XMLHttpRequest,textStatus,errorThrown) {
            alert("Error:"+textStatus);
            alert(errorThrown.toString());
        }
    }); 
}
</script>
</html>